using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class DocRegRefRelMap : EntityTypeConfiguration<DocRegRefRel>
	{
		public DocRegRefRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("DocRegRefRels");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DoctorId).HasColumnName("DoctorId");
			this.Property(t => t.DoctorExtId).HasColumnName("DoctorExtId");
			this.Property(t => t.RegistrationId).HasColumnName("RegistrationId");
			this.Property(t => t.IsExtDoctor).HasColumnName("IsExtDoctor");

			// Relationships
			this.HasOptional(t => t.DoctorExt)
				.WithMany(t => t.DocRegRefRels)
				.HasForeignKey(d => d.DoctorExtId);
				
			this.HasOptional(t => t.Doctor)
				.WithMany(t => t.DocRegRefRels)
				.HasForeignKey(d => d.DoctorId);
				
			this.HasOptional(t => t.PatientReg)
				.WithMany(t => t.DocRegRefRels)
				.HasForeignKey(d => d.RegistrationId);
				
		}
	}
}

